package com.bwie.doctor.service.impl;

import com.bwie.common.core.domain.Result;
import com.bwie.common.security.utils.SecurityUtils;
import com.bwie.doctor.domain.po.MedOrderDetails;
import com.bwie.doctor.domain.vo.MedOrderDetailsQuery;
import com.bwie.doctor.domain.vo.MedOrderDetailsVo;
import com.bwie.doctor.mapper.MedOrderDetailsMapper;
import com.bwie.doctor.service.MedOrderDetailsService;
import com.bwie.system.api.model.LoginUser;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class MedOrderDetailsServiceImpl implements MedOrderDetailsService {
    @Autowired
    private MedOrderDetailsMapper medOrderDetailsMapper;
    /**
     * 医生收入列表
     * @return
     */
    @Override
    public Result queryIncomeList(MedOrderDetailsQuery medOrderDetailsQuery) {
        //方法
//        Long userId = getLoginUserId();
//        medOrderDetails.setDoctorId(1L);
        List<MedOrderDetailsQuery> medOrderDetailsQueries = medOrderDetailsMapper.queryIncomeList(medOrderDetailsQuery);
        return Result.success(medOrderDetailsQueries);
    }

    /**
     * 医生订单列表
     */
    @Override
    public Result queryOrderList(Integer consultationType) {
        List<MedOrderDetailsVo> medOrderDetailsVos = medOrderDetailsMapper.queryOrderList(consultationType);
        return Result.success(medOrderDetailsVos);
    }
    /**
     * 患者订单详情
     */
    @Override
    public Result queryOrderDetails(Long orderId) {
        MedOrderDetailsVo medOrderDetailsVo = medOrderDetailsMapper.queryOrderDetails(orderId);
        return Result.success(medOrderDetailsVo);
    }

    /**
     * 获取登录人的id
     */
    private Long getLoginUserId() {
        LoginUser loginUser = SecurityUtils.getLoginUser();
        Long userid = loginUser.getUserid();
        return userid;
    }
}
